#pragma once

#include <boost/asio.hpp>
#include <boost/asio/spawn.hpp>
#include <memory>
#include <queue>
#include <thread>
#include <unordered_map>

namespace UTILS {

class TCPServer : public std::enable_shared_from_this<TCPServer> {
private:
  boost::asio::ip::tcp::acceptor m_acceptor_;
  std::atomic_bool m_isStop_;
  decltype(boost::asio::make_work_guard(
      m_acceptor_.get_executor())) m_workGuard_;

private:
  boost::asio::awaitable<void> accept();

public:
  TCPServer(boost::asio::io_context &, const boost::asio::ip::tcp::endpoint &);
  void start();
  void stop();
  ~TCPServer();
  void read();
  void write();
};
} // namespace UTILS